import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "vant/lib/index.css";
// 导入初始化css
import './assets/css/base.css'
// 引入js适配移动端文件
import './assets/js/phone'
// import Axios from 'axios';//引入axios
// 引入vant库
// import '@/plugins/vant'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import {
  Tabbar,
  TabbarItem,
  NavBar,
  Button,
  Icon,
  Rate,
  Cell,
  Image as VanImage,
  Form,
  Field,
  CellGroup,
  NoticeBar,
  Swipe, SwipeItem,
  Pagination 
} from "vant";

// 路由导航守卫
router.beforeEach((to,from,next)=>{
  if(!localStorage.getItem('phone')){
    if(to.path !== '/login'){
      next('/login')
    }else{
      next()
    }
  }else{
    next()
  }
})

createApp(App)
  .use(ElementPlus)
  .use(store)
  .use(router)
  .use(Tabbar)
  .use(TabbarItem)
  .use(NavBar)
  .use(Button)
  .use(Icon)
  .use(Rate)
  .use(Cell)
  .use(VanImage)
  .use(Field)
  .use(CellGroup)
  .use(Form)
  .use(NoticeBar)
  .use(Swipe)
  .use(SwipeItem)
  .use(Pagination )
  .mount("#app");
